function [ A ] = computeSensingMatrix( MWC)
%COMPUTESENSINGMATRIX Summary of this function goes here
%   Detailed explanation goes here

M = MWC.M;
L = MWC.L;
q = MWC.q;

S = MWC.SignPatterns;
if (mod(L,2)==0)
    L=L+1;
end   % L is the number of specturm slices, namely the length of z[n]
L0 = (L-1)/2;
q_tag = floor(q/2);

L0_tild =L0 + q_tag;
L_tild = 2*L0_tild+1;

[x,y]=meshgrid(L0_tild:-1:-L0_tild,0:1:M-1);
F = exp(ones(M,L_tild)*(-2*pi*1j/M).*x.*y);

theta = exp(-1j*2*pi/M);
np = L0_tild:-1:1;
nn = -1:-1:(-L0_tild);
dn = [   (1-theta.^np)./(1j*2*pi*np)      1/M    (1-theta.^nn)./(1j*2*pi*nn)  ];
D = diag(dn);
% A = conj(S*F*D);
Aextended = S*F*D;

[rows,~]=size(Aextended);
%compute A by samart select of indices from Aextended 

A=zeros(rows * q,L);

for channel=1:rows
    
    for k=0:q-1
        A( (channel-1)*q + k+1,:) = Aextended(channel,q-k:end-k);
    end
    
end
    
    
end

